package com.hassean.we.admin.common.util.template;

/**
 * Created by yajun on 2019/4/13.
 */
public class ThreadUtil {
    public   void ThreadUtilMath() {
        // run in a second
        final long timeInterval = 1000;
        Runnable runnable = new Runnable() {
            Boolean flag = true;
            public void run() {
                while (flag) {
                    try {
                        Thread.sleep(timeInterval);
                        System.out.println("我是线程 !!,我只执行一次");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    // flag = false;//关闭线程
                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();

    }


    //测试定时线程发送短信
    public void ThreadsetTime5(Long timeInterval) {
        Runnable runnable = new Runnable() {
            Boolean flag = true;
            public void run() {
                while (flag) {
                    try {
                        Thread.sleep(timeInterval);
                        System.out.println("我是测试定时线程!!,我在等待-----");
                        flag = false;
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();

    }
}

